22 template <class T
> string
toStr(const T
&x
){ stringstream s
; s
<< x
; return s
.str(); }
23 template <class T
> int toInt(const T
&x
){ stringstream s
; s
<< x
; int r
; s
>> r
; return r
; }
25 #define For(i, a, b) for (int i=(a); i<(b); ++i)
26 #define foreach(x, v) for (typeof (v).begin() x = (v).begin(); x != (v).end(); ++x)
27 #define D(x) cout << #x " = " << (x) << endl
32 while (cin
>> n
>> m
){
33 if (n
== 0 && m
== 0) break;
35 for (int i
=0; i
<n
; ++i
){
40 for (int i
=0; i
<k
; ++i
){